import java.util.StringTokenizer;

class P10324 {

	public static void main(String[] args) {
		int cases = 1;
		int[] line = readLnInt();
		while (line != null) {
			System.out.println("Case " + cases + ":");
			cases++;
			process(line);
			
			line = readLnInt();
		}
	}

	private static void process(int[] line) {
		int queries = Integer.parseInt(readLn());
		for (int k = 0; k < queries; k++) {
			StringTokenizer st = new StringTokenizer(readLn());
			int i = Integer.parseInt(st.nextToken());
			int j = Integer.parseInt(st.nextToken());
			int begin = i < j ? i : j;
			int end = i > j ? i : j;
			
			boolean answer = line[begin] == line[end];
						
			System.out.println(answer ? "Yes" : "No");
		}
		
	}

	static int[] readLnInt() {
		int[] answer = new int[1000000];
		int index = -1;
		int putter = -1;
		int c = -1;
		String newLine = System.getProperty("line.separator");
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				index++;
				if (c != car) {
					c = car;
					putter = index;
				}
				answer[index] = putter;
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (index == -1))
			return (null);
		return answer;
	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}
